from rest_framework import serializers
from goods.models import SPU,Brand,GoodsCategory

class SPUViewSetviewSerializer(serializers.ModelSerializer):
    #1.重写brand
    brand=serializers.StringRelatedField(read_only=True)
    brand_id=serializers.IntegerField()
    #2,重写category
    category1 = serializers.StringRelatedField(read_only=True)
    category1_id = serializers.IntegerField()

    category2 = serializers.StringRelatedField(read_only=True)
    category2_id = serializers.IntegerField()

    category3 = serializers.StringRelatedField(read_only=True)
    category3_id = serializers.IntegerField()

    class Meta:
        model=SPU
        fields="__all__"

#spu新增规格序列化器
class SPUBrandSimpleSerializers(serializers.ModelSerializer):
    class Meta:
        model=Brand
        fields="__all__"
#一级分类信息序列话器
class SPUCategorySerializers(serializers.ModelSerializer):
    class Meta:
        model=GoodsCategory
        fields="__all__"

